Add GdkGLContext::profile
authorAlexander Larsson <alexl@redhat.com>
Thu, 30 Oct 2014 11:42:37 +0000 (12:42 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Oct 2014 11:43:03 +0000 (12:43 +0100)
gdk/gdkglcontext.c
gdk/gdkglcontext.h
gdk/wayland/gdkglcontext-wayland.c
gdk/x11/gdkglcontext-x11.c

index f64c23d13694e2e800759293027c71b4fd1578ac..48f444a5947e3e5dd26b62fe77093c6a95eae236 100644 (file)
@@ -81,6 +81,7 @@
 typedef struct {
   GdkWindow *window;
   GdkGLContext *shared_context;
+  GdkGLProfile profile;
 
   guint realized : 1;
   guint use_texture_rectangle : 1;
@@ -91,6 +92,7 @@ enum {
   PROP_0,
 
   PROP_WINDOW,
+  PROP_PROFILE,
   PROP_SHARED_CONTEXT,
 
   LAST_PROP
@@ -154,6 +156,10 @@ gdk_gl_context_set_property (GObject      *gobject,
       }
       break;
 
+    case PROP_PROFILE:
+      priv->profile = g_value_get_enum (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
     }
@@ -177,6 +183,10 @@ gdk_gl_context_get_property (GObject    *gobject,
       g_value_set_object (value, priv->shared_context);
       break;
 
+    case PROP_PROFILE:
+      g_value_set_enum (value, priv->profile);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
     }
@@ -203,6 +213,23 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
                          G_PARAM_CONSTRUCT_ONLY |
                          G_PARAM_STATIC_STRINGS);
 
+  /**
+   * GdkGLContext:profile:
+   *
+   * The #GdkGLProfile of the context
+   *
+   * Since: 3.16
+   */
+  obj_pspecs[PROP_PROFILE] =
+    g_param_spec_enum ("profile",
+                       P_("Profile"),
+                       P_("The GL profile the context was created for"),
+                       GDK_TYPE_GL_PROFILE,
+                       GDK_GL_PROFILE_DEFAULT,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT_ONLY |
+                       G_PARAM_STATIC_STRINGS);
+
   /**
    * GdkGLContext:shared-context:
    *
@@ -330,6 +357,26 @@ gdk_gl_context_get_window (GdkGLContext *context)
   return priv->window;
 }
 
+/**
+ * gdk_gl_context_get_profile:
+ * @context: a #GdkGLContext
+ *
+ * Retrieves the #GdkGLProfile that @context was created for.
+ *
+ * Returns: a #GdkGLProfile
+ *
+ * Since: 3.16
+ */
+GdkGLProfile
+gdk_gl_context_get_profile (GdkGLContext *context)
+{
+  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+  g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), GDK_GL_PROFILE_LEGACY);
+
+  return priv->profile;
+}
+
 /**
  * gdk_gl_context_get_shared_context:
  * @context: a #GdkGLContext
index 599ec99435f2e04367f81d6003fd9eb8c5ff7b4f..e78e9b44b7168b225fc885e681339eb3f4c524f9 100644 (file)
@@ -44,6 +44,8 @@ GType gdk_gl_context_get_type (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_3_16
 GdkWindow *             gdk_gl_context_get_window       (GdkGLContext *context);
+GDK_AVAILABLE_IN_3_16
+GdkGLProfile            gdk_gl_context_get_profile      (GdkGLContext *context);
 
 GDK_AVAILABLE_IN_3_16
 void                    gdk_gl_context_make_current     (GdkGLContext *context);
index 7af884e7f071ead63ac025fc8f1991f0ce749bb3..4c80a802de0685d1b37ba7174bf9ac312e8dae32 100644 (file)
@@ -326,6 +326,9 @@ gdk_wayland_window_create_gl_context (GdkWindow     *window,
       return NULL;
     }
 
+  if (profile == GDK_GL_PROFILE_DEFAULT)
+    profile = GDK_GL_PROFILE_LEGACY;
+
   if (profile == GDK_GL_PROFILE_3_2_CORE &&
       !display_wayland->have_egl_khr_create_context)
     {
@@ -363,6 +366,7 @@ gdk_wayland_window_create_gl_context (GdkWindow     *window,
 
   context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
                           "window", window,
+                          "profile", profile,
                           "shared-context", share,
                           NULL);
 
index e1a578e4300a634dd70c716e4caca094578e5b0f..9c2d9a9751276c15cc08dcb565d9b8ba23c66148 100644 (file)
@@ -1043,6 +1043,7 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
       /* GDK_GL_PROFILE_DEFAULT is currently
        * equivalent to the LEGACY profile
        */
+      profile = GDK_GL_PROFILE_LEGACY;
       glx_context = create_gl_context (display, config, share);
     }
 
@@ -1119,6 +1120,7 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
 
   context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
                           "window", window,
+                          "profile", profile,
                           "shared-context", share,
                           NULL);